<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>测试scrollTotop</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<style type="text/css">
	#container1{background-color:#BFDA00;}
	#container2{
		background-color:#2EBE21;
		height: 2008px;
	}
	#container3{
		background-color:antiquewhite;
		  margin: 10px;
	}
</style>


</head>
<body>

<div id="container2" >456
	<div id="container3">789</div>
</div>
</body>
<script type="text/javascript">
var mTop = document.getElementById('container3').offsetTop;//div到浏览器顶端的距离
     var cTop = $('#container3').scrollTop();//div到浏览器顶端的距离
    var sTop = $(window).scrollTop(); 
    console.log("第一个offsetTop"+mTop);
    console.log("第一个cTop"+cTop);
    console.log("第一个scrollTop"+sTop); 
    
window.onscroll = function (e) {   
    var mTop = document.getElementById('container3').offsetTop;//div到浏览器顶端的距离
     var cTop = $('#container3').scrollTop();//div到浏览器顶端的距离
    var sTop = $(window).scrollTop(); 
    console.log("offsetTop"+mTop);
    console.log("cTop"+cTop);
    console.log("scrollTop"+sTop);         

}

</script>
</html>